"""

查看数据轴向spacing分布
"""

import os
import sys
sys.path.append(os.path.split(sys.path[0])[0])

import SimpleITK as sitk

from config import parameter as para

spacing_list = []

root = para.data_root  # cut之后,n*256*256的数据

with open(para.label_and_unlabel_id_path, 'r') as f:
    ids = f.read().splitlines()
for id in ids:
    file=os.path.join(root,id.split(' ')[0])
    # 将CT和标签入读内存
    volume = sitk.ReadImage(os.path.join(para.vol_path, file), sitk.sitkInt16)
    #print('处理前的volume shape:',volume_array.shape,end = '   ')
    temp=volume.GetSpacing()[-1]

    spacing_list.append(temp)
print(spacing_list.count(1.0))
spacing_list.sort()
print(spacing_list)

# 训练集中的平均spacing是1.59mm
# 测试集中的数据的spacing都是1mm
